#ifndef MASTER_PROCESS_H
#define MASTER_PROCESS_H

#include "bsp_usart.h"
#include "seasky_protocol.h"

#define VISION_RECV_SIZE 18u // 当前为固定值,36字节
#define VISION_SEND_SIZE 36u


#pragma pack(1)
//————————————————发送的所有结构体——————————————//
typedef enum
{
	NO_FIRE = 0,
	AUTO_FIRE = 1,
	AUTO_AIM = 2,
	AUTO_PRED = 3,
	AUTO_LARGE = 4
} Fire_Mode_e;

typedef enum
{
	NO_TARGET = 0,
	TARGET_CONVERGING = 1,
	READY_TO_FIRE = 2
} Target_State_e;

typedef enum
{
	NO_TARGET_NUM = 0,
	HERO1 = 1,
	ENGINEER2 = 2,
	INFANTRY3 = 3,
	INFANTRY4 = 4,
	INFANTRY5 = 5,
	OUTPOST = 6,
	SENTRY = 7,
	BASE = 8
} Target_Type_e;

typedef struct
{
	Fire_Mode_e fire_mode;
	Target_State_e target_state;
	Target_Type_e target_type;

	float pitch;
	float yaw;
} Vision_Recv_s;

typedef enum
{
	COLOR_NONE = 0,
	COLOR_BLUE = 1,
	COLOR_RED = 2,
} Enemy_Color_e;

typedef enum
{
	VISION_MODE_AIM = 0,
	VISION_MODE_SMALL_BUFF = 1,
	VISION_MODE_BIG_BUFF = 2
} Work_Mode_e;

typedef enum
{
	BULLET_SPEED_NONE = 0,
	BIG_AMU_10 = 10,
	SMALL_AMU_15 = 15,
	BIG_AMU_16 = 16,
	SMALL_AMU_18 = 18,
	SMALL_AMU_30 = 30,
} Bullet_Speed_e;
//————————————————————————end————————————————————————//
//湖大通信结构体
typedef struct
{
	Enemy_Color_e enemy_color;
	Work_Mode_e work_mode;
	Bullet_Speed_e bullet_speed;

	float yaw;
	float pitch;
	float roll;
} Vision_Send_s;


#pragma pack()


//中南大学的结构体声明
#pragma pack(1)
typedef struct
{
	uint8_t header;						//帧头
	Enemy_Color_e enemy_color;       	// 敌方颜色
	//Work_Mode_e work_mode;
	//Bullet_Speed_e bullet_speed;

	float pitch;
	float yaw;
	uint16_t current_HP; 				// 当前血量
	uint16_t stage_remain_time;			// 当前阶段剩余时间
	uint8_t game_status;				// 游戏状态
	uint16_t game_progress;				// 游戏进度
	// int16_t allow_fire_amount; //允许发射的子弹数量
	
	//float vel_x;
	//float vel_y;
	//float gimabl_angle;
	//float gimbal_send;
	
	//float current_enemy_sentry_hp;
	//float current_enemy_base_hp;
	//float current_shield_hp;
	//float current_base_hp;
	//float current_outpost_hp; //当前前哨站血量
	//float current_enemy_outpost_hp; //当前敌方前哨站血量

	//云台手控制信息
	uint8_t cmd_enable;					// 命令使能
	float cmd_x;						// 命令X轴
	float cmd_y;						// 命令Y轴
	//uint8_t reserved;
	uint8_t i; 							//不清楚作用
	float roll;							//不清楚作用
    uint8_t ender;						//帧尾

} RV_Send_Packet_s;


typedef struct
{
	//---------------------------------------哨兵通信需要---------------------------------------
	uint8_t header;                     //帧头
	Fire_Mode_e fire_mode;				//上位机这边仅仅只有Fire或者NotFire		// uint8_t fire_accept;     
	Target_State_e target_state;		//
	Target_Type_e target_type;          //机器人编号

	float pitch;                        //pitch
    float yaw;							//小yaw
	//思考雷达是左手系还是右手系
	float vel_x;						//雷达发送的Vx
    float vel_y;						//雷达发送的Vy
	float angle;
	// uint32_t RfidStatus;				//RFID	
	float gimbal_select;				//选择大小YAW
	
	uint8_t chassis_mode;               //底盘模式选择
	uint8_t dabian;

    uint8_t reserved;	
    uint8_t ender; 						//帧尾
	//---------------------------------------哨兵通信需要---------------------------------------



} RV_Receive_Packet_s;
#pragma pack()



/**
 * @brief 调用此函数初始化和视觉的串口通信
 *
 * @param handle 用于和视觉通信的串口handle(C板上一般为USART1,丝印为USART2,4pin)
 */
Vision_Recv_s *VisionInit(UART_HandleTypeDef *_handle);

/**
 * @brief 发送视觉数据（湖大）
 *
 */
void VisionSend();

/**
 * @brief 设置视觉发送标志位
 *
 * @param enemy_color
 * @param work_mode
 * @param bullet_speed
 */
void VisionSetFlag(Enemy_Color_e enemy_color, Work_Mode_e work_mode, Bullet_Speed_e bullet_speed);

/**
 * @brief 设置发送数据的姿态部分
 *
 * @param yaw
 * @param pitch
 */
void VisionSetAltitude(float yaw, float pitch, float roll);


/**
 * @brief 中南的通信，设置发送数据的姿态部分
 * 
 * @param yaw
 * @param pitch
 * 感觉可以不要roll
 * 
*/
void RVSetAttitude(float yaw, float pitch, float roll);

/**
 * @brief 发送视觉数据（中南）
 *
 */
void RV_VisionSend();
/**
 * @brief 中南的通信，得到裁判系统的数据
 */
void RVRefreeSetAltitude(uint16_t current_HP,uint16_t stage_remain_time,uint8_t game_status,uint16_t game_progress);

void RVVisionSetFlag(Enemy_Color_e enemy_color);

/**
 * @brief 调用此函数初始化和视觉的串口通信
 *
 * @param handle 用于和视觉通信的串口handle(C板上一般为USART1,丝印为USART2,4pin)
 */
RV_Receive_Packet_s *RV_VisionInit(UART_HandleTypeDef *_handle);




#endif // !MASTER_PROCESS_H